import { createApp } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import { createStore } from 'vuex'

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {path: '/home', component: () => import('./pages/home.vue'), name: 'main'},
    {path: '/login', component: () => import('./pages/login.vue')}
  ]
})

const store = createStore({
  state() {
    return {
      username: '__user_',
      menus: undefined,
      windowWidth: NaN,
    }
  },
  mutations: {
    username(state, payload) {
      state.username = payload
    },
    menus(state, payload) {
      state.menus = payload
    },
    windowWidth(state, payload) {
      state.windowWidth = payload
    }
  }
})

const app = createApp(App)
app.use(ElementPlus)
app.use(router)
app.use(store)
app.mount('#app')
